package com.atguigu.gmall.order.client;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.order.OrderInfo;
import com.atguigu.gmall.order.client.impl.OrderDegradeFeignClient;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;


import java.util.Map;

@FeignClient(value = "service-order" ,fallback = OrderDegradeFeignClient.class)
@Repository
public interface OrderFeignClient {
    @GetMapping("/api/order/auth/trade")
    public Result<Map<String, Object>> trade();
    //    public Result<Map<String, Object>> trade(HttpServletRequest request);
//    不写request进行了统一的拦截  微服务之间没有传递头文件信息{cookie用户名}
//    通过feign 订单页面在feign拦截器中创建了request请求
    @GetMapping("/api/order/inner/getOrderInfo/{orderId}")
    public OrderInfo getOrderInfo(@PathVariable Long orderId);

    /**
     * 提交秒杀订单
     * @param orderInfo
     * @return
     */
    @PostMapping("/api/order/inner/seckill/submitOrder")
    Long submitOrder(@RequestBody OrderInfo orderInfo);

}
